package edu.java.homework.hw03.introJava11;

import java.util.Random;
import java.util.Scanner;

public class Exercises {

    public static void main(String[] args) {
	// exercise 01 --> print the seconds, minutes, hours and days from
	// 1.01.1970 to now
	// exer01();

	// exercise 02 --> calculates the hypothesis after the user inputs the 2
	// cathetuses
//	exer02();

	//exercise 03 --> print random selected advertisement 
	System.out.println(exer05());
    }

    /**
     * print the seconds, minutes, hours and days from 1.01.1970 to now
     */
    public static void exer01() {
	long milliSeconds = System.currentTimeMillis();
	long seconds = milliSeconds / 1000;
	long minutes = seconds / 60;
	long hours = minutes / 60;
	int days = (int) hours / 24;

	System.out.printf("Seconds: %d\n", seconds);
	System.out.printf("Minutes: %d\n", minutes);
	System.out.printf("Hours: %d\n", hours);
	System.out.printf("Days: %d\n", days);
    }

    /**
     * calculates the hypothesis after the user inputs the 2 cathetuses
     */
    public static void exer02() {
	Scanner input = new Scanner(System.in);
	double cath1 = 0.0d;
	double cath2 = 0.0d;
	double hypo = 0.0d;
	System.out.print("Cathetus 1: ");
	cath1 = input.nextDouble();
	System.out.print("Cathetus 2: ");
	cath2 = input.nextDouble();
	hypo = Math.sqrt(Math.pow(cath1, 2) + Math.pow(cath2, 2));
	System.out.printf("Hypothesis: %.2f", hypo);
    }

    public static String exer05() {
	String result = null;
	String[] phrase = { "Продуктът е отличен.",
		"Това е  страхотен продукт.",
		"Постоянно  ползвам  този  продукт.",
		"Това  е  най-добрият продукт от тази категория." };

	String[] event = { "Вече  се  чувствам  добре.",
		"Успях  да  се променя.", "Той направи чудо.",
		"Не мога да повярвам, но вече се чувствам страхотно.",
		"Опитайте и вие. Аз съм мнjого доволна." };

	String[] firstName = { "Диана", "Петя", "Стела", "Елена", "Катя" };
	String[] secondName = { "Иванова", "Петрова", "Кирова" };
	String[] city = { "София", "Пловдив", "Варна", "Русе", "Бургас" };

	Random rand = new Random();
	int phraseRandPos = rand.nextInt(phrase.length);
	int eventRandPos = rand.nextInt(event.length);
	int fNameRandPos = rand.nextInt(firstName.length);
	int sNameRandPos = rand.nextInt(secondName.length);
	int cityRandPos = rand.nextInt(city.length);

	result = phrase[phraseRandPos] + "   " + event[eventRandPos] + "\n"
		+ firstName[fNameRandPos] + " " + secondName[sNameRandPos]
		+ ", " + city[cityRandPos];

	return result;
    }

}
